Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the DSO selector search behavior to support prefix/partial-word matching for communities/collections by translating user input into a backend startsWith filter, keeping Solr-specific syntax out of the Angular UI.
Changes:
- Add query normalization (trim/empty handling) and conditional
f.dc.title+startsWithfiltering for COMMUNITY/COLLECTION searches inDSOSelectorComponent.search. - Extend unit tests to cover the new query/filter behavior (but the current PR includes unresolved merge-conflict markers).
- Minor formatting cleanup in
AuthorizedCollectionSelectorComponentand small test refactor attempt.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/app/shared/dso-selector/dso-selector/dso-selector.component.ts |
Implements trimmed-query handling and conditional startsWith filter for community/collection searches. |
src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts |
Attempts to add test coverage for query processing; currently contains merge-conflict markers and an unused import. |
src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts |
Formatting-only change in mapping/payload construction. |
src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.spec.ts |
Adds helper/fixture values, but currently leaves unused declarations that likely fail linting. |
Comment on lines
+162
to
+248
| <<<<<<< Updated upstream | ||
| ======= | ||
| describe('query processing', () => { | ||
| beforeEach(() => { | ||
| spyOn(searchService, 'search').and.callThrough(); | ||
| }); | ||
|
|
||
| describe('for COMMUNITY/COLLECTION types', () => { | ||
| beforeEach(() => { | ||
| component.types = [DSpaceObjectType.COMMUNITY]; | ||
| }); | ||
|
|
||
| it('should use a title startsWith filter for community/collection searches', () => { | ||
| component.search('test query', 1); | ||
|
|
||
| expect(searchService.search).toHaveBeenCalledWith( | ||
| jasmine.objectContaining({ | ||
| query: '', | ||
| filters: [jasmine.objectContaining({ | ||
| key: 'f.dc.title', | ||
| values: ['test query'], | ||
| operator: 'startsWith' | ||
| })] | ||
| }), | ||
| null, | ||
| true | ||
| ); | ||
| }); | ||
|
|
||
| it('should pass through internal resource ID queries unchanged', () => { | ||
| const resourceIdQuery = component.getCurrentDSOQuery(); | ||
| component.search(resourceIdQuery, 1); | ||
|
|
||
| expect(searchService.search).toHaveBeenCalledWith( | ||
| jasmine.objectContaining({ | ||
| query: resourceIdQuery | ||
| }), | ||
| null, | ||
| true | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('for ITEM types', () => { | ||
| beforeEach(() => { | ||
| component.types = [DSpaceObjectType.ITEM]; | ||
| }); | ||
|
|
||
| it('should pass through queries unchanged', () => { | ||
| component.search('test query', 1); | ||
|
|
||
| expect(searchService.search).toHaveBeenCalledWith( | ||
| jasmine.objectContaining({ | ||
| query: 'test query' | ||
| }), | ||
| null, | ||
| true | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('edge cases', () => { | ||
| beforeEach(() => { | ||
| component.types = [DSpaceObjectType.COMMUNITY]; | ||
| }); | ||
|
|
||
| it('should treat whitespace-only query as empty and apply default sort', () => { | ||
| component.sort = new SortOptions('dc.title', SortDirection.ASC); | ||
| component.search(' ', 1); | ||
|
|
||
| expect(searchService.search).toHaveBeenCalledWith( | ||
| jasmine.objectContaining({ | ||
| query: '', | ||
| filters: undefined, | ||
| sort: jasmine.objectContaining({ | ||
| field: 'dc.title', | ||
| direction: SortDirection.ASC, | ||
| }), | ||
| }), | ||
| null, | ||
| true | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| >>>>>>> Stashed changes |
| import { createPaginatedList } from '../../testing/utils.test'; | ||
| import { NotificationsService } from '../../notifications/notifications.service'; | ||
| import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; | ||
| import { SearchFilter } from '../../search/models/search-filter.model'; |
Comment on lines
+24
to
+29
| function createCollection(id: string, name: string): Collection { | ||
| return Object.assign(new Collection(), { id, name }); | ||
| } | ||
|
|
||
| const collectionTest = createCollection('col-test', 'test'); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem description
Analysis
(Write here, if there is needed describe some specific problem. Erase it, when it is not needed.)
Problems
(Write here, if some unexpected problems occur during solving issues. Erase it, when it is not needed.)
Sync verification
If en.json5 or cs.json5 translation files were updated:
yarn run sync-i18n -t src/assets/i18n/cs.json5 -ito synchronize messages, and changes are included in this PR.Manual Testing (if applicable)
Copilot review